package messaging;

message Packet 
{
    //包类型字段
    enum PacketType 
    {
        GET_MACHINE_INFO = 0;      //请求机器信息
        MACHINE_INFO = 1;          //机器信息-machine_info

        SET_CAMERA_COUNT = 2;     //设置相机个数-camera_count

        GET_CAMERA_INFO = 3;      //请求相机信息-CameraInfoRequest
        CAMERA_INFO = 4;          //所有相机信息-camera_info
        
        GET_LANE_INFO = 5;         //请求车道信息-lane_info_request
        LANE_INFO     = 6;         //车道信息-lane_info
        
        GET_LANE_LPR_PARMS = 7;    //请求车道车牌识别参数-lane_info_request
        LANE_LPR_PARMS = 8;        //车道车牌识别参数-lane_lpr_info

        SET_MACHINE_IP      = 9;        //设置机器ip-ip_info
        REGISTER_MACHINE    = 10;        //注册机器-registration_info
        REBOOT              = 11;       //重启命令-reboot_parm
        SYNC_TIME           = 12;       //同步时间-time_parm
    }
    required PacketType packet_type = 1;
    //包类型字段结束

    //数据字段
    optional MachineInfo machine_info = 2;

    optional CameraCount camera_count = 3;

    optional CameraInfoRequest camera_info_request = 4;
    optional CameraInfo camera_info = 5;
    optional LaneInfoRequest lane_info_request = 6;
    optional LaneInfo lane_info = 7;
    optional LaneLprParms lane_lpr_info = 8;

    
    optional MachineIp ip_info = 9;
    optional RegistrationInfo registration_info = 10;
    optional RebootParm reboot_parm = 11;
    optional TimeParm time_parm = 12;
}


message RebootParm //重启命令
{
    enum Target { MACHINE = 0; PROCESS = 1; }
    required Target target = 1;
}

message TimeParm //同步时间
{
    required uint64 time = 1;
}


message RegistrationInfo //注册信息
{
    required string registration_code = 1; //注册码
}


message MachineIp //配置机器ip
{
    required string ip = 1;				//ip	
}

message CameraCount //配置相机个数
{
    required uint32 count = 1;
}

message MachineInfo //机器信息
{
    required string ip = 1;				//机器ip	
    required string hardward_id = 2;	//机器硬件id，用来注册时使用
    required uint64 current_time = 3;   //机器当前时间
    required bool is_registered = 4;	//机器是否注册

    required uint32 camera_count = 5;   //摄像机个数
}

message CameraInfos //所有相机信息
{
    repeated CameraInfo cameras = 1;  //相机信息（多个）
}



message LaneInfoRequest
{
    required uint32 id_number = 1;
}

message LaneInfo //车道信息
{
    required uint32 camera_id_number = 1;   //所属相机编号

    required uint32 id_number = 2;			//车道编号
    required uint32 speed_limit = 3;		//速度限制
}


message LaneLprParmsRequest
{
    required uint32 id_number = 1;
}

message LaneLprParms
{
    required uint32 camera_id_number = 1;   //相机编号
    required uint32 id_number = 2;     //车道编号

    required Rectangle detect_region = 3;       //检测区域
    required StretchFactor stretch_factor = 4;  //拉伸因子
}

message CameraInfoRequest   //请求单个相机信息
{
    required uint32 id_number = 1;  //相机编号
}

message CameraInfo //单个相机信息
{
    required uint32 id_number = 1;			//相机编号
    required string ip = 2;					//相机ip

    required string station_number = 3;      //监控点编号
    required string station_name = 4;		 //监控点名称
    required string direction_number = 5;    //方向编号
    required string direction_name = 6;		 //方向名称

    required uint32 lanes_count = 7;          //所监控的车道数目
    required uint32 start_lane_number = 8;    //所监控的起始车道编号
}

message Rectangle
{
    required uint32 x = 1;
    required uint32 y = 2;
    required uint32 w = 3;
    required uint32 h = 4;
}

message StretchFactor
{
    required float near_camera_factor = 1;
    required float far_camera_factor = 2;
}